<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>  
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
	<div>
		url地址：<input type="text" name="reqUrl" id="reqUrl" /></br>
		方法：
		<select id="reqMethod">
			<option value="get">GET</option>
			<option value="post">POST</option>
		</select></br>
		请求参数：</br>
		<input type="button" id="add" value="+" /></br>
		<div class="reqPar">
			<input type="text" name="key1" id="key1" value="" />
			<input type="text" name="val1" id="val1" value="" /></br>
		</div>
		
		<input type="button" id="sub" value="测试" /></br>
		<textarea  cols="50" rows="10" id="content"></textarea>
	</div>
<script>
	var i = 1;
	$('#add').on('click',function(){
		var str = '<input type="text" name="key'+(i+1)+'" id="key'+(i+1)+'" value="" />'+
			'<input type="text" name="val'+(i+1)+'" id="val'+(i+1)+'" value="" /></br>';
		$('.reqPar').append(str);
		i++;
	})
	function par(){
		for(var k=0;k<i;k++){
			$('')
		}
	}
	$(function(){
		$('#sub').click(function(){
			if(undefined==$('#reqUrl').val()||''==$('#reqUrl').val()
					||undefined==$('#reqMethod').val()||''==$('#reqMethod').val())
			{
				alert('请完善')
				return false;
			}
			$.ajax({
                type: "POST",
                url: "postman.json",
                dataType:'json',
                data: {
                	reqUrl:$('#reqUrl').val(),
                	reqMethod:$('#reqMethod').val(),
                	interName:$('#interName').val()
                },
                success: function(opResult){
                	$('#content').text(opResult.result);
                },
                error:function (XMLHttpRequest, textStatus, errorThrown) {
                	$('#content').html('请求失败');
                	alert(XMLHttpRequest.status);
                	/*alert(XMLHttpRequest.readyState);
                	alert(textStatus);
                	alert('操作失败');*/
                }
            });
		})
	})
</script>
</body>
</html>